package laborhazi;

public class Table {
	private Element[] elementTable = null;
	private int pos;
	
	public Table() {
		pos = 0;
		elementTable = new Element[200];
	}
	public void add(Element n) {
		
		if ( pos == 198) 
			return ;
		else {
    		elementTable[pos] = n;
    		++pos;
		}	
	}
	public void sort() {
		int outer, inner;
		 for(outer = pos - 1; outer > 0; --outer)  // outer loop (backward)
		     for(inner = 0; inner < outer; ++inner)    // inner loop (forward)
		      if( elementTable[inner].isSmaller(elementTable[inner + 1]) )    // out of order?
		        this.swap(inner, inner + 1);     // swap them
	}
	public void swap(int first, int second) {
		Element temp = null;
		temp = elementTable[first];
		elementTable[first] = elementTable[second];
		elementTable[second] = temp;
	}
	public String getName(int actual) {
		if (actual < pos) {
			return elementTable[actual].name;
		}
		return null;
	}
	public int getScore(int actual) {
		if (actual < pos) {
			return elementTable[actual].value;
		}
		return -1;
	}
	public int getPos() {
		
		return pos;
	}
}
